#pragma once
#include<iostream>
#include<pthread.h>



namespace Lock
{

    class Mutex
    {
    public:
        Mutex(const Mutex&) = delete;
        const Mutex& operator=(const Mutex&) = delete;
        Mutex()
        {
            int n = pthread_mutex_init(&mut,nullptr);
            (void)n;
        }
        ~Mutex()
        {
            int n =pthread_mutex_destroy(&mut);
             (void)n;
        }
        void Lock()
        {
            int n = pthread_mutex_lock(&mut);
             (void)n;
        }
        void unLock()
        {
            int n =pthread_mutex_unlock(&mut);
            (void) n;
        }
        pthread_mutex_t *LockPtr()
        {
            return &mut;
        } 

    private:

    pthread_mutex_t mut;
    };

    class LockGuard
    {
        public:
       LockGuard(Mutex &mtx)
       :_lock(mtx)
        {
            _lock.Lock();
        }
        ~LockGuard()
        {
            _lock.unLock();
        }

        private:
        Mutex &_lock;
    };



}